/**
 * Copyright (c) 2008 Luciano Bustos - riaevolution.com, All Rights Reserved.
 * 
 * Contact luchyx@riaevolution.com
 * See www.riaevolution.com
 *  
 * Permission is hereby granted, free of charge, to any person obtaining a copy of 
 * this software and associated documentation files (the "Software"), to deal in 
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all 
 * copies or substantial portions of the Software.
 * 
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE. 
 * */
 
package com.riaevolution.components
{
	import mx.controls.Alert;
	import mx.core.mx_internal;

	/**
	 * 
	 * Alerter provide a simple way to manage diferent ways of an alert notification to the user.
	 * It allow you to display alerts, infos, confirmations alerts.
	 * If you want a modal input handler or a complex input handler
	 * 
	 * @see com.riaevolution.components.ModalPromptHandler
	 * 
	 * @example this snippet show to the user an information message (not critical) .
	 * <listing version="3.0">Alerter.info('your email was succcefull submited!');</listing>
	 * 
	 * Author luciano bustos
	 */	
	public class Alerter extends Alert
	{
		
		[Embed(source="icons/warning-32.png")]
		public static var iconWarning:Class;
		
		[Embed(source="icons/error_icon16x16.png")]
		public static var iconError:Class;
		
		[Embed(source="icons/information-32.png")]
		public static var iconInfo:Class;
		
		[Embed(source="icons/question-32.png")]
		public static var iconConfirm:Class;
		
		use namespace mx.core.mx_internal;
		
		public static function info(message:String,title:String='Information',closehandler:Function=null):Alert {
			var t:Alert = show(message, title, Alert.OK, null, closehandler, iconInfo);
			t.alertForm.textField.htmlText = message;
			t.styleName = 'AlerterInfo';
			return t;
		}
		
		public static function error(message:String, title:String='Error',closehandler:Function=null):Alert {
			var t:Alert = show(message,title, Alert.OK, null, closehandler, iconError);
			t.alertForm.textField.htmlText = message;
			t.styleName = 'AlerterError';
			return t;
		}
		
		public static function confirmError(message:String,title:String='Error', closehandler:Function=null):Alert {
			var t:Alert = show(message, title, Alert.YES | Alert.NO, null, closehandler, iconWarning);
			t.alertForm.textField.htmlText = message;
			t.styleName = 'AlerterConfirmError';
			return t;
		}
		public static function confirm(message:String,title:String='Confirmation', closehandler:Function=null):Alert {
			var t:Alert = show(message, title, Alert.YES | Alert.NO,null, closehandler, iconConfirm);
			t.alertForm.textField.htmlText = message;
			t.styleName = 'AlerterConfirm';
			return t;
		}
		
		public static const YES:int = 4;
		public static const OK:int = 1;
		public static const CANCEL:int = 2;

	}
}